package com.util
{
	import com.game.raceroom.player.MapInfo;
	
	public class DEF
	{
		public function DEF()
		{
		}
		static public var time:Date=new Date();
		static public var MOVE_STEP:Number=20;
		
        static public var GAME_CANVAS_X:int =0;
        static public var GAME_CANVAS_Y:int =0;
        static public var GAME_CANVAS_WIDTH:int =780;
        static public var GAME_CANVAS_HEIGHT:int =540;
        
        static public var FRAME_RATE:int=40;
        static public var SPEED_UP_FRAME_RATE:int=50;
        static public var FRAME_WAP_COUNT:int=5;
        
 	    static public var  KEY_UP:int = 38;
  		static public var  KEY_DOWN:int = 40;
  		static public var  KEY_LEFT:int= 37;
  		static public var  KEY_RIGHT:int = 39;
		static public var  KEY_W:int = 87;
		static public var  KEY_S:int = 83;
		static public var  KEY_A:int = 65;
		static public var  KEY_D:int = 68;
		static public var  KEY_SPACE:int = 32;
		static public var  KEY_ENTER:int = 13;
		
		static public var  KEY_1:int = 49;	
		static public var  KEY_1_:int = 97;	
		static public var  KEY_2:int = 50;	
		static public var  KEY_2_:int = 98;	
		static public var  KEY_3:int = 51;	
		static public var  KEY_3_:int = 99;	
		static public var  KEY_4:int = 52;	
		static public var  KEY_4_:int = 100;	
		static public var  KEY_5:int = 53;	
		static public var  KEY_5_:int = 101;	
		static public var  KEY_6:int = 54;	
		static public var  KEY_6_:int = 102;	
		static public var  KEY_7:int = 55;	
		static public var  KEY_7_:int = 103;	
		static public var  KEY_8:int = 56;	
		static public var  KEY_8_:int = 104;	
		
				
		static public var  DIRECTION_UP:int      	= 0x00000000;
		static public var  DIRECTION_DOWN:int 		= 0x00000100;
		static public var  DIRECTION_LEFT:int 		= 0x00000200;
		static public var  DIRECTION_RIGHT:int		= 0x00000300;
		static public var  DIRECTION_UP_LEFT:int 	= 0x00000400;
		static public var  DIRECTION_DOWN_LEFT:int 	= 0x00000500;
		static public var  DIRECTION_UP_RIGHT:int 	= 0x00000600;
		static public var  DIRECTION_DOWN_RIGHT:int = 0x00000700;
		static public var  DIRECTION_STOP:int 		= 0x00000800;
		
	    static public var ACTION_HEAD:String="#ACT";
	    static public var ACTION_MOVE:int=0;
	    static public var ACTION_ACTION:int=1;	
	    static public var ACTION_CRASH:int=2;	
	    static public var ACTION_USEITEM:int=3;
	    static public var ACTION_EFFECT:int=4;
	    static public var ACTION_CASTSKILL:int=5;
	    static public var ACTION_ADDITEM:int=6;
		//不可通过  不损失动能，耐久
		static public var  TILE_TYPE_NOTPASS:int = 0;
		//建筑物 障碍物
		static public var  TILE_TYPE_BUILDING:int = 1;
		//公路
		static public var  TILE_TYPE_ROAD:int = 2;
		//草地
		static public var  TILE_TYPE_GRASS:int = 3;
		//土地
		static public var  TILE_TYPE_LAND:int = 4;
		//沙地
		static public var  TILE_TYPE_SAND:int = 5;
		//水面
		static public var  TILE_TYPE_WATER:int = 6;
		//冰面
		static public var  TILE_TYPE_ICE:int = 7;
		//雪地
		static public var  TILE_TYPE_SNOW:int = 8;
		//泥泽
		static public var  TILE_TYPE_MUD:int = 9;
		//深坑
		static public var  TILE_TYPE_HOLE:int = 10;



	static public  var  CTS_FT_LOGIN:int     		= 0;
	static public  var  CTS_FT_START   :int   		= 1;
	static public  var  CTS_FT_ACTION  :int    		= 2;
	static public  var  CTS_FT_SKILL :int     		= 3;
	static public  var  CTS_FT_SKILL_STRICK :int     		= 4;
	     
	    static public var  sinTable:Array =
	    [0     ,0.2588 ,0.5    ,0.7071 ,0.866  ,0.9659 ,
	     1     ,0.9659 ,0.866  ,0.7071 ,0.5    ,0.2588 ,
	     0     ,-0.2588,-0.5   ,-0.7071,-0.866 ,-0.9659,
	     -1    ,-0.9659,-0.866 ,-0.7071,-0.5   ,-0.2588];
	    static public var  cosTable:Array =
	    [1     ,0.9659 ,0.866  ,0.7071 ,0.5    ,0.2588 ,
	     0     ,-0.2588,-0.5   ,-0.7071,-0.866 ,-0.9659,
	     -1    ,-0.9659,-0.866 ,-0.7071,-0.5   ,-0.2588,
	     0     ,0.2588 ,0.5    ,0.7071 ,0.866  ,0.9659 ];
	     
//	   	public static function getTestCar1(dis:ActorDisplayer):CarInfo{
//			var car:CarInfo=new CarInfo(dis,"game/img/actor/car_"+random(0,3)+".swf");
//
//			car.turnCft=0.25;
//			car.evnCft=40;
//			car.maxUpSpeed=600/1000;
//			car.maxDownSpeed=150/1000;
//			car.accCft=0.00055;
//			car.braCft=0.00035;
//		    car.confRadius=40;
//		    car.weight=1000;
//		    car.sideClipCft=1.0;
//	        return car;
//		}
//	   	public static function getTestCar2(dis:ActorDisplayer):CarInfo{
//			var car:CarInfo=new CarInfo(dis,"game/img/actor/car_"+random(0,3)+".swf");
//
//			car.turnCft=0.25;
//			car.evnCft=40;
//			car.maxUpSpeed=600/1000;
//			car.maxDownSpeed=150/1000;
//			car.accCft=0.00055;
//			car.braCft=0.00035;
//		    car.confRadius=40;
//		    car.weight=1000;
//		    car.sideClipCft=1.0;
//	        return car;
//		}
		public static function getTestMap(id:int):MapInfo{
			var map:MapInfo=new MapInfo;
			map.mapid=id;
			map.firctCft=1.0;
            map.tileKitId=0;
            if(id==2){

			  map.gride=2049;
			  map.tileDataId=2;
			  map.mapName="冰原";
			}else
			if(id==1){

			  map.gride=2049;
			  map.tileDataId=1;
			  map.mapName="克里夫村";
			}else{

			   map.gride=2049;
			  map.tileDataId=0;
			  map.mapName="广场空地";
			}
	        return map;
		}
	
        public static function cInt(p:Number):int
        {
        	return p*1000;
        }	

        public static function cDouble(p:int):Number
        {
        	return p*0.001;
        }	
	
		public static function decimal2(p:Number):Number{
			p=Number(p.toFixed(4));  
			return p;
		}
  
  

	
	
		public static function GenerateCheckCode():String
		{
			//初始化
			var ran:Number;
			var number:Number;
			var code:String;
			var checkCode:String ="";
			//生成四位随机数
			for(var i:int=0; i<4; i++)
			{
			//Math.random生成数为类似为0.1234
			ran=Math.random();
			number =Math.round(ran*10000);
			//如果是2的倍数生成一个数字
			if(number % 2 == 0)
			//"0"的ASCII码是48
			code = String.fromCharCode(48+(number % 10));
			//生成一个字母
			else
			//"A"的ASCII码为65
			code = String.fromCharCode(65+(number % 26)) ;
			checkCode += code;
			}
			return checkCode;
		}
		
		static var ran:Number;
		public static function  random(min:int,max:int):int{
			if(min==max)return min;
			if(min>max){
				return 0;
			}
			ran=Math.random();
			ran=(ran*100)/(100/(max-min+1));
			ran=Math.floor(ran);
		    ran=ran+min;
			if(ran>max)ran=max;
			return ran;
		}	
	}

}